package com.baidu.lib_common.utils

import android.content.Context
import android.content.res.Resources

fun dp2px(dp: Int): Int {
    return (Resources.getSystem().displayMetrics.density * dp).toInt()
}

fun dp2pxF(dp: Int): Float {
    return Resources.getSystem().displayMetrics.density * dp
}
fun getStatusBarHeight(context: Context): Int {
    var result = 0
    // 查找系统定义的状态栏高度资源ID
    val resourceId = context.resources.getIdentifier(
        "status_bar_height",
        "dimen",
        "android"
    )
    if (resourceId > 0) {
        // 通过资源ID获取具体的像素值
        result = context.resources.getDimensionPixelSize(resourceId)
    }
    return result
}